<template>
	<view>
		<view class="searchBox">
			<view class="search">
				<view class="address">{{address}}</view>
				<uni-icons class="icon" type="bottom"></uni-icons>
				<view>
					<!-- 搜搜轮播 -->
					<swiper @change="swiperchange" style="height: 70rpx;width: 300rpx;"  vertical="true" autoplay="true" interval="4000" circular>
						<swiper-item style="height: 70rpx;width: 300rpx;"  v-for="(item,index) in swipersearchList" :key="index">
							<view style="font-size: 28rpx;color: #999; height: 70rpx;width: 300rpx;line-height: 70rpx;">{{item.storeName}}</view>
						</swiper-item>
					</swiper>
				</view>
			</view>
			<view @click="toSearch" class="rightBox">
				<view class="iconBox">
					<uni-icons color="white" class="icon" type="arrow-right"></uni-icons>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {reactive, ref,getCurrentInstance,onMounted} from 'vue'
	import {onLoad} from "@dcloudio/uni-app"
	import {storeToRefs} from "pinia";//结构才需要引入
	import {useNavStore} from '@/store/index.js'//引入空间
	const navStore = useNavStore()//给空间命名
	const {address} = storeToRefs(navStore);//解构数据
	const {proxy} = getCurrentInstance()
	const swipersearchList = ref([])
	onMounted(()=>{
		swipersearch()
	})
	//搜索滚动
	const swipersearch=async()=>{
		const result = await proxy.$api.searchswiper()
		if(result.code==200){
			swipersearchList.value = result.data
		}
	}
	const swiperid = ref('')
	const swiperchange=(e)=>{
		swiperid.value = e.detail.current
	}
	const toSearch=()=> {
		var id=swipersearchList.value[swiperid.value].id
		var title=swipersearchList.value[swiperid.value].storeName
		uni.navigateTo({
			url: '/pages-detail/search/search?value=' + title+'&id='+id
		})
	}
</script>

<style lang="scss">
.searchBox {
		position: relative;
		z-index: +10;
		padding: 0 20px;
		height: 66rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-top: 20rpx;
	
		.address {
			font-size: 14px;
			margin-right: 2px;
		}
	
		.search {
			display: flex;
			align-items: center;
			padding: 0 10px;
			background-color: white;
			border-radius: 10px;
			width: calc(100% - 80px);
	
			.icon {
				margin-right: 10px;
			}
		}
	
		.rightBox {
			background: $linerBlue;
			padding: 9px;
			border-radius: 9px;
	
			.iconBox {
				width: 16px;
				height: 16px;
				display: flex;
				justify-content: center;
				align-items: center;
	
				.icon {
					color: white !important;
					font-size: 16px !important;
					font-weight: bold;
				}
			}
		}
	}
</style>
